[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+-------+##################################################################
#+-| COUNT |-------------------------------------------------+################
#| +-------+ The COUNT command counts the records within the |################
#| [Scope] of the current or selected alias and |################
#| then assigns the result to <Long_var> |################
#+-----------------------------------------------------------+################
##############################################################################
##############################################################################
#+--| Syntax |------------------------------------+###########################
#| [!<Alias>] COUNT [Scope] [FOR <L-exp>] |###########################
#| [WHILE <L-exp> TO <Long-var> |###########################
#+------------------------------------------------+###########################
##############################################################################
##############################################################################
#######+---| Description |-------------------------------------------+########
#######| The default scope of COUNT is ALL. <Long-var> may not be a |########
#######| field variable. |########
#######+-------------------------------------------------------------+########
##############################################################################
##############################################################################
#########+--| Example 1 |-------------------------------------------+#########
#########| * Find out how many people in North Dakota |#########
#########| * scuba dive. |#########
#########| |#########
#########| VARDEF |#########
#########| Long scuba_total |#########
#########| ENDDEF |#########
#########| |#########
#########| DBFDEF census |#########
#########| CHAR(2) state |#########
#########| LOGICAL scuba |#########
#########| ENDDEF |#########
#########| |#########
#########| PROCEDURE force_main |#########
#########| |#########
#########| USE "census.dbf" ALIAS census |#########
#########| COUNT ALL FOR census->state = 'ND' ; |#########
#########| .AND. census->scuba TO scuba_total |#########
#########| ? scuba_total |#########
#########| |#########
#########| ENDPRO |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| * Find out if more dogs are placed in kennels |#########
#########| * than were placed 10 years ago. |#########
#########| |#########
#########| !bookings_1 COUNT FOR bookings_1->animal = 'dog' ; |#########
#########| TO dog_one |#########
#########| !bookings_10 COUNT FOR bookings_10->animal = 'dog' ; |#########
#########| TO dog_two |#########
#########| |#########
#########| RETURN dog_two > dog_one |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 3 |-------------------------------------------+#########
#########| * Continue counting until a key is pressed. |#########
#########| |#########
#########| COUNT FOR dexp() WHILE is_key() = TO total_val |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 4 |-------------------------------------------+#########
#########| * How many records are deleted in a database. |#########
#########| * This is a generic routine for any database. |#########
#########| |#########
#########| PROCEDURE delete_total |#########
#########| PARAMETERS ALIAS d, LONG del_count |#########
#########| |#########
#########| !d COUNT FOR deleted() TO del_count |#########
#########| |#########
#########| ENDPRO |#########
#########| |#########
#########| {...} |#########
#########| DO delete_total WITH dt |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
AVERAGE
SUM
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson